/**
 * Copyright 1998-2006, CHISEL Group, University of Victoria, Victoria, BC, Canada.
 * All rights reserved.
 */
package ca.uvic.cs.cogz.mapping.core;

import java.awt.Color;
import java.awt.Stroke;
import java.util.Collection;

import ca.uvic.cs.cogz.mapping.core.MappingTypeManager.MappingType;
import edu.stanford.smi.protege.model.Frame;
import edu.stanford.smi.protege.model.Slot;

/**
 * Implementation of an actual verified mapping element. This is a mapping that has been verified by
 * the user and saved to the mapping ontology.
 * 
 * @author Sean Falconer
 * @date 10-Jan-07
 */
public class VerifiedMapElement extends AbstractMapElement {
	public VerifiedMapElement(Collection<Frame> sourcePath, Collection<Frame> targetPath, String annotation) {
		init(sourcePath, targetPath, annotation);
	}

	private void init(Collection<Frame> sourcePath, Collection<Frame> targetPath, String annotation) {
		this.sourcePath = sourcePath;
		this.targetPath = targetPath;
		this.annotation = annotation;

		this.color = DEFAULT_LINE_COLOR;
		this.highlightColor = HIGHLIGHT_LINE_COLOR;
		this.selectedColor = DEFAULT_LINE_COLOR;

		this.thickness = DEFAULT_LINE_THICKNESS;
		this.dashed = DEFAULT_DASHED_LINE;

		Object[] path1 = sourcePath.toArray();
		sourceFrame = (Frame) path1[path1.length - 1];

		Object[] path2 = targetPath.toArray();
		targetFrame = (Frame) path2[path2.length - 1];
		
		if(sourceFrame instanceof Slot && targetFrame instanceof Slot) {
			this.color = new Color(134, 54, 55);
			this.selectedColor = new Color(134, 54, 55);
			//this.dashed = true;
		}

		updateStrokeAndPreview();
	}
	
	public Stroke getStroke() {
		if(sourceFrame instanceof Slot && targetFrame instanceof Slot) {
			return thinStroke;
		}
		if (highlight || selected) {
			return thickStroke;
		}

		return thinStroke;
	}

	public MappingType getMappingType() {
		return MappingType.VERIFIED_MAPPING;
	}
}
